<!-- 佣金 -->
<template>
	<view class="content">
		<view class="user">
			<view style="position: relative;">
				<image class="user_back" src="/static/distribution.png" mode="widthFix"></image>
				<view class="income">
					<view class="key_val">
						<view class="key">当前收益</view>
						<view class="val">{{money}}</view>
					</view>
					<view class="but" @click="but">申请提现</view>
				</view>
			</view>
			
			<view class="share">
				<view class="share_title">
					<view class="icon"></view>
					<text>佣金明细</text>
				</view>
				<ul v-if="yjList.length>0">
					<li v-for="item in yjList" :key="item.id">
						<view class="title_money">
							<view class="title">{{item.title}}</view>
							<view class="money">{{item.price}}</view>
						</view>
						<view class="nick_name" v-if="item.msg">昵称：{{item.msg}}</view>
						<!-- <view class="nick_name">下单时间：{{item.time}}</view> -->
					</li>
					<!-- <li>
						<view class="title_money">
							<view class="title">申请提现</view>
							<view class="money">+30</view>
						</view>
					</li> -->
				</ul>
				<view style="text-align: center;padding: 30rpx 0;font-size: 26rpx;color: #999;" v-else>暂无数据</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const request = require('../../utils/request');
	export default {
		data() {
			return {
				money:0,
				page:1,
				yjList:[],
				khtype:2
			}
		},
		onLoad(e) {
			this.khtype = Number(e.type);
			uni.setNavigationBarTitle({
			    title: e.type==2?"我的团队佣金":"我的客户佣金"
			});
		},
		onShow() {
			this.yjList = [];
			this.kh_lists();
		},
		methods: {
			but(){
				uni.navigateTo({
					url:'/pages/my/withdrawal?type='+this.khtype
				})
			},
			onOrder(id){
				if(id>0){
					uni.navigateTo({
						url:'/pages/order/orderdetail?order_id='+id
					})
				}
			},
			kh_lists:function(){
				var that = this;
				//网络请求
				request(app.globalData.api_url+'/v1/user/yj_lists', 'POST', {
					page:that.page,
					khtype:that.khtype
				}).then((res) => {
					if(res.data.code == 0){
						console.log(res);
						that.yjList = that.yjList.concat(res.data.data);
						that.money = res.data.yongjin;
					}else{
						uni.showToast({
							title:res.data.msg,
							icon:'none'
						});
						app.is_login_check(res.data);
					}
				});
			}
		},
		onReachBottom() {
			this.page++;
			this.yj_lists();
		}
	}
</script>

<style scoped lang="scss">
	.user{
		position: relative;
		.user_back{
			width: 100%;
		}
		.income{
			width: 90%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%,-50%);
			z-index: 9999;
			.key{
				font-size:30rpx;
				color: #fff;
				letter-spacing: 2rpx;
			}
			.val{
				font-size:50rpx;
				color: #fff;
				letter-spacing: 2rpx;
			}
			.but{
				width: 160rpx;
				height: 64rpx;
				border-radius: 50rpx;
				background-color: #fff;
				color: #38c763;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 26rpx;
				line-height: 26rpx;
			}
		}
		.share{
			background-color: #fff;
			margin: -100rpx 36rpx 0;
			box-shadow: -1rpx 2rpx 24rpx 0rpx rgba(144,144,144,0.36);
			position: relative;
			border-radius: 10rpx;
			.share_title{
				display: flex;
				align-items: center;
				padding-top: 30rpx;
				.icon{
					width: 8rpx;
					height: 28rpx;
					background-color: #38c763;
					margin-right: 10rpx;
				}
				text{
					font-size: 30rpx;
					font-weight: 600;
					color:#000
				}
			}
			ul{
				padding:0 30rpx;
				li{
					padding: 30rpx 0;
					border-bottom: 2rpx solid #f1f1f1;
					.title_money{
						display: flex;
						align-items: flex-end;
						justify-content: space-between;
						.title{
							width: 70%;
							font-size: 28rpx;
							color: #333;
							line-height: 40rpx;
							letter-spacing: 2rpx;
						}
						.money{
							color: red;
							font-size: 34rpx;
							font-weight: 600;
						}
					}
					.nick_name{
						font-size: 26rpx;
						line-height: 26rpx;
						color:#999;
						margin-top: 20rpx;
					}
				}
			}
		}
		.team_client{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 80rpx 36rpx 0;
			.team, .client{
				width: 38%;
				height: 106rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 30rpx;
				border-radius: 20rpx;
				text{
					color: #000;
					font-size: 30rpx;
				}
				image{
					width: 70rpx;
					height: 70rpx;
				}
			}
			.team{
				background-color: #38c763;
			}
			.client{
				background-color: #38c763;
			}
		}
	
	}
</style>
